<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri='http://java.sun.com/jsp/jstl/core' prefix='c'%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>View user</title>
</head>
<body>

<c:if test="${ not empty sessionScope.user }">
	<a href="./LogoutController">Log out</a> <br/>
	<a href="./editUser.jsp">Edit personal information</a> <br/>
</c:if>
<c:if test="${ empty sessionScope.user }">
	<a href="./login.jsp">Log in</a> <br>
	<a href="./register.jsp">Register</a><br/>
</c:if>
<a href="./LastCommentsController?id=${ requestScope.viewedUser.id }">Last comments</a> <br/>
<a href="./HomeController">Home</a> <br/>

<c:if test="${ requestScope.viewedUser.id ne sessionScope.user.id }">
	<a href="./RSSController?id=${ requestScope.viewedUser.id }">RSS</a><br/>
	
	<c:if test="${ requestScope.viewedUser.id ne requestScope.user.id }">
		
		<c:if test="${ requestScope.followed }">
			<a href="./UnfollowController?idunfollow=${ requestScope.viewedUser.id }" > Unfollow </a>
		</c:if>
		
		<c:if test="${ not requestScope.followed }">
			<a href="./FollowController?idfollow=${ requestScope.viewedUser.id }" > Follow </a>
		</c:if>
		
	</c:if>
	
</c:if>

<table>
	<tr>
		<td>User information:</td>
	</tr>
	<tr>
		<td rowspan="7"><a href=${ requestScope.viewedUser.profileImage.location }><img alt="Greška, nema slike" src="${requestScope.viewedUser.profileImage.thumbnailLocation}"></a></td>		
	</tr>
	<tr>
		<td>Name</td>
		<td>${ requestScope.viewedUser.firstname } ${ requestScope.viewedUser.lastname }</td>
	</tr>
	<tr>
		<td>Email</td>
		<td>${ requestScope.viewedUser.emailAddress }</td>
	</tr>
	<tr>
		<td>Gender</td>
		<td>${ requestScope.viewedUser.gender }</td>
	</tr>
	<tr>
		<td>Date of birth</td>
		<td>${ requestScope.viewedUser.dateOfBirth }</td>
	</tr>
</table>

<h2>Albums:</h2>
<table>
	<c:forEach var="album" items="${userAlbums}">
		<c:if test="${ album.publiclyAvailable }">
			<tr>
				<td> <label>Album title: </label> </td>
				<td>
					<a href="./ViewAlbumController?id=${album.id}">
					<c:out value="${album.title}"/>
					</a>
				</td>
			</tr>
		</c:if>
	</c:forEach>
</table>

</body>
</html>